package com.qf.smartplatform.websocket;

import com.qf.smartplatform.events.CommandEvent;
import org.springframework.stereotype.Controller;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;

/**
 * projectName:day12_27_Test
 * author:guoLei
 * time:2022/1/10 14:32
 * description:
 */
@Controller
public class MyCommandHandler extends MyBaseCommandHandler{
    public static void sendControl(CommandEvent event){
        Object object=event.getCommand();
        String uid = event.getUid();
        WebSocketSession session = getAllClients().get(uid);
        if (session != null&&session.isOpen()) {
            try {
                session.sendMessage(new TextMessage(object.toString()));
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
